-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
buffer: disallow ArrayBuffer transfer on pooled buffer #61372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Review requested:
|
I don't believe so – calling |
|
https://chromium-review.googlesource.com/c/v8/v8/+/7454288 would be required to have |
Original commit message:
[builtins] disallow ArrayBuffer transfer with a detach key
This allows embedder to disallow `ArrayBuffer.prototype.transfer()` on
an arraybuffer that is not detachable. This also fix the check on
`ArrayBufferCopyAndDetach` step 8 of `ArrayBuffer.prototype.transfer`.
Refs: nodejs#61362
Refs: https://tc39.es/ecma262/#sec-arraybuffercopyanddetach
Change-Id: I3c6e156a8fad007fd100218d8b16aed5c4e1db68
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7454288
Commit-Queue: Chengzhong Wu <[email protected]>
Reviewed-by: Olivier Flückiger <[email protected]>
Cr-Commit-Position: refs/heads/main@{#104697}
Refs: v8/v8@c5ff7c4
cd3d626 to
749c2fc
Compare
| obj[untransferable_object_private_symbol] = true; | ||
|
|
||
| if (isArrayBuffer(obj)) { | ||
| setDetachKey(obj, Symbol('unique_detach_key_for_untransferable_arraybuffer')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ linter comment seems applicable
|
|
||
| // This would better be placed in internal/worker/io.js, but that doesn't work | ||
| // because Buffer needs this and that would introduce a cyclic dependency. | ||
| function markAsUntransferable(obj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a public method on the worker_threads module, I'd suggest adding a documentation update there (and I'd say this doesn't count as a breaking change, since it is very much in line with the intent of this method)
749c2fc to
70fcbd5
Compare
| obj[untransferable_object_private_symbol] = true; | ||
|
|
||
| if (isArrayBuffer(obj)) { | ||
| setDetachKey(obj, Symbol('unique_detach_key_for_untransferable_arraybuffer')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: is there any disadvantage to making this a static key, rather than generating a new symbol for each invocation?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61372 +/- ##
==========================================
- Coverage 88.51% 87.91% -0.60%
==========================================
Files 704 702 -2
Lines 208776 208395 -381
Branches 40301 40125 -176
==========================================
- Hits 184803 183220 -1583
- Misses 15966 17470 +1504
+ Partials 8007 7705 -302
🚀 New features to boost your workflow:
|
deps: V8: cherry-pick c5ff7c4d6cde
Original commit message:
Refs: v8/v8@c5ff7c4
buffer: disallow ArrayBuffer transfer on pooled buffer
This is an alternative solution that disallows transfer operation on buffer pool.
Depends on https://chromium-review.googlesource.com/c/v8/v8/+/7454288.
Fixes: #61362